#include<stdio.h>
#include<stdlib.h>
/**
*  Tutorial #12 (Array Index and Address)
*  Program for Exchange Sort Using Pointers
**/
int main(){
    int n,ar[10],i;
    printf("Enter the value of n\n");
    scanf("%d",&n);
    printf("Enter the array\n");
    for(i = 0; i < n;i++){
        scanf("%d",ar+i);
    }
    printf("Sorted values are:\n");
    exchangeSort(ar,n);
    for(i = 0;i<n;i++){
        printf("%d",*(ar+i));
    }
}

void exchangeSort(int *ar,int n){
    int i,j;
    for(i = 0;i<n;i++){
        for(j = i+1;j<n;j++){
            if(*(ar+i) > *(ar+j)){
                int temp = *(ar+i);
                *(ar+i) = *(ar+j);
                *(ar+j) = temp;
            }
        }
    }
}
